package com.sk.weichat.ui.circle;

import android.content.Context;
import android.content.Intent;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.sk.weichat.R;
import com.sk.weichat.ui.base.BaseActivity;
import com.sk.weichat.util.ViewPiexlUtil;

/**
 * @author lzs
 * @date 2019/10/30
 * Email:343067508@qq.com
 * 地点动态列表
 **/
public class DynamicOfOnePlaceActivity extends BaseActivity {

    public static final void startDynamicOfOnePlaceActivity(Context context, String location) {
        Intent intent = new Intent(context, DynamicOfOnePlaceActivity.class);
        intent.putExtra("location", location);
        context.startActivity(intent);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_dynamic_of_place);
        findViewById(R.id.iv_title_left).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        String location = getIntent() != null ? TextUtils.isEmpty(getIntent().getStringExtra("location")) ? "" : getIntent().getStringExtra("location") : "";

        TextView tvTitle = findViewById(R.id.tv_title_center);
        tvTitle.setText(location);
        Drawable drawableLeft = getResources().getDrawable(R.drawable.icon_title_loaction);
        drawableLeft.setBounds(new Rect(0, 0, drawableLeft.getIntrinsicWidth(), drawableLeft.getIntrinsicHeight()));
        tvTitle.setCompoundDrawablePadding(ViewPiexlUtil.dp2px(mContext,3));
        tvTitle.setCompoundDrawables(drawableLeft, null, null, null);

        FollowerDynamicsFragment followerDynamicsFragment = new FollowerDynamicsFragment();
        Bundle data = new Bundle();
        data.putString("location", location);
        followerDynamicsFragment.setArguments(data);
        getSupportFragmentManager().beginTransaction().replace(R.id.content, followerDynamicsFragment).commit();


        findViewById(R.id.iv_add_dynamic).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //跳转发动态页面
                startActivity(new Intent(mContext, PublishDynamicActivity.class).putExtra("flag", 5));
            }
        });

    }
}
